package com.ronin.pkimg.helper;

import com.baidu.aip.ocr.AipOcr;

public class OcrHelper {

    //设置APPID/AK/SK
    private static final String APP_ID = "18836831";
    private static final String API_KEY = "Djfg3YgZuuUir7f7EsnTKqfj";
    private static final String SECRET_KEY = "hwVanrFkxSZA2XOuqsXfnpL3Vt6Frd0U";
    private volatile AipOcr client;

    public static OcrHelper getInstance() {
        return Holder.INSTANCE;
    }

    private OcrHelper() {
        init();
    }

    private void init() {

        // 初始化一个AipOcr
        client = new AipOcr(APP_ID, API_KEY, SECRET_KEY);

        // 可选：设置网络连接参数
        client.setConnectionTimeoutInMillis(2000);
        client.setSocketTimeoutInMillis(60000);

        // 可选：设置代理服务器地址, http和socket二选一，或者均不设置
//        client.setHttpProxy("proxy_host", proxy_port);  // 设置http代理
//        client.setSocketProxy("proxy_host", proxy_port);  // 设置socket代理
    }

    public AipOcr getClient() {
        return client;
    }


    private static class Holder {
        private static final OcrHelper INSTANCE = new OcrHelper();
    }


}
